<?php
$this->breadcrumbs = array(
    'Users' => array('index'),
    'Manage',
);

$this->menu = array(
    array('label' => 'List User', 'url' => array('index')),
    array('label' => 'Create User', 'url' => array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('user-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Users</h1>
<?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button btn')).'<br><hr>'; ?>
<div class="search-form" style="display:none">
    <?php
    $this->renderPartial('_search', array(
        'model' => $model,
    ));
    ?>
</div><!-- search-form -->
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'enableAjaxValidation' => TRUE,
        ));
?>
<script>
    function reloadGrid(data) {
        $.fn.yiiGridView.update('user-grid');
    }
</script>
<?php echo CHtml::ajaxSubmitButton('Hiển thị', array('user/ajaxUpdate', 'act' => 'doActive'), array('success' => 'reloadGrid')); ?>
<?php echo CHtml::ajaxSubmitButton('Ẩn', array('user/ajaxUpdate', 'act' => 'doInactive'), array('success' => 'reloadGrid')); ?>
<?php // echo CHtml::ajaxSubmitButton('Xóa', array('user/ajaxUpdate', 'act' => 'doDelete'), array('success' => 'reloadGrid', 'beforeSend' => 'function(){
//            return confirm("Bạn có chắc chắn muốn xóa những Styles đã chọn?")
//        }',)); ?>
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'user-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        array(
            'id' => 'autoId',
            'class' => 'CCheckBoxColumn',
            'selectableRows' => '50',
        ),
        array(
            'name' => 'id',
            'header' => 'ID',
            'htmlOptions' => array('style' => 'width:50px;')
        ),
        'username',
        'email',
        'fullname',
        array(
            'name' => 'status',
            'header' => 'Trạng thái',
            'filter' => array('1' => 'Hiển thị', '0' => 'Ẩn'),
            'value' => '($data->status=="1")?("Hiển thị"):("Ẩn")'
        ),
        /*
          'phone_no',
          'dob',
          'address',
          'gender',
          'status',
          'login_type',
          'last_visited',
          'created_at',
          'role',
         */
        array(
            'class' => 'bootstrap.widgets.TbButtonColumn',
            'template' => '{view} {update}',
        ),
    ),
));
?>
<?php $this->endWidget(); ?>
